/*
 * © Copyright 2011 Romain Marteau, Matthieu Totet
 * 
 *    This file is part of VineaToum.
 *
 *    VineaToum is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    VineaToum is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with VineaToum.  If not, see <http://www.gnu.org/licenses/>.
 *    
 */

package org.vineatoum.business.action.operationpassive;

import java.util.Date;
import java.util.Vector;

import org.vineatoum.business.action.abstraction.PassiveOperation;
import org.vineatoum.business.enumeration.ETypeOxygenation;
import org.vineatoum.view.utils.jtablecustom.TableListener;

public class Oxygenation extends PassiveOperation {
	private final String DATE = "Date de l'Oxygénation";
	private final String DUREE = "Durée (min)";
	private final String TYPE = "Type";
	
	protected Float duree;
	protected ETypeOxygenation type = null;
	
	
	public Oxygenation() {
		duree = new Float(30);
	}
	
	public Float getDuree() {
		return duree;
	}

	public void setDuree(Float duree) {
		this.duree = duree;
	}
	
	public ETypeOxygenation getType() {
		return type;
	}

	public void setType(ETypeOxygenation type) {
		this.type = type;
	}
	
	@Override
	public TableListener getNewInstance() {
		return new Oxygenation();
	}

	@Override
	public Vector<String> getVectorColumns() {
		Vector<String> vector = new Vector<String>();
		
		vector.add(DATE);
		vector.add(DUREE);
		vector.add(TYPE);
		
		return vector;
	}

	@Override
	public Vector<Object> getVectorData() {
		Vector<Object> vector = new Vector<Object>();
		
		vector.add(date);
		vector.add(duree);
		vector.add(type);
		
		return vector;
	}

	@Override
	public void updateField(String field, Object value) {
		try {
			if(field == DATE) {
				date = (Date)value;
			} else if (field == DUREE) {
				duree = (Float)value;
			} else if (field == TYPE) {
				type = (ETypeOxygenation) value;
			}
		} catch (Exception e) {
			System.err.println("error parsing in Oxygenation for field " + field);
			// TODO: handle exception
		}
	}
}
